#ifndef PARSER_H_
#define PARSER_H_

#include "Object.h"

#include <string>
#include <stdlib.h>
#include <vector>

using namespace std;

class Parser : public Object {
public:
	Parser();
	Parser( string f );

	~Parser();

	string getFunction() { return function; }
	void setFunction( string f ) { function = f; }

	double calculate(string s);
	vector<double> getY( vector<double> x );
	vector<double> generateX( double from, double to, double step );
	vector<double> getDiff( vector<double> y );

	double operator[](string s) { return calculate(s); }
	vector<double> operator[](vector<double> x) { return getY(x); }

	string toString() { return "Parser"; }
private:
	string strReplace( string str, string searchString, string replaceString );
	double readNumber( const char* start, int* length );
	string readFunction( string function, double* v );
	int getLength( double n );
	void removeSpaces();

	int pos;
	string function;
};

#endif /* PARSER_H_ */
